package com.qidian.tcba.admin.api.controller;


import com.qidian.tcba.admin.model.dto.user.UserAnnouncementsDTO;
import com.qidian.tcba.admin.service.AnnouncementService;
import com.qidian.tcba.utils.result.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 通知表 前端控制器
 * </p>
 *
 * @author 冯永龙
 * @since 2021-07-06
 */
@RestController
@RequestMapping("/announcement")
@Api(tags ="消息")
public class AnnouncementController {

    private final AnnouncementService announcementService;

    public AnnouncementController(AnnouncementService announcementService) {
        this.announcementService = announcementService;
    }

    @ApiOperation(value = "获取消息通知列表",notes = "根据用户id，当前页数和每页多少条数据获取")
    @GetMapping("/getAll/{userId}/{page}/{size}")
    public JsonResult getUserAnnouncementList(@PathVariable("userId")int userId,@PathVariable("page")int page, @PathVariable("size")int size){
        List<UserAnnouncementsDTO> userAnnouncements = announcementService.getUserAnnouncements(userId,page, size);
        return JsonResult.success().data("rows",userAnnouncements);
    }
}

